﻿@{
    ViewBag.Title = "Detail";
    Layout = "~/Views/Shared/_LayoutIndex.cshtml";
}

<link href="~/Content/styles/BillDetail.css?v=1.1" rel="stylesheet" />
<script src="~/Content/scripts/jquery/ajaxfileupload.js"></script>

<script>
    var keyValue = request('keyValue');
    var list = [];
    var deviceTypeId = "", Title = "1", logo = "1", SaveFlag = 1;
    var organizeId = "@LeSoft.Application.Code.OperatorProvider.Provider.Current().CompanyId", _TypeId = "@ViewBag.Type", _ParentId = "", _PStructId = "";
    $(function () {
        InitialPage();
        initControl();
    });

    //设置隐藏
    function setDisplay(int) {
        switch (int) {
            case 1: {
                $("#BaseInfo").show();
                $("#DeviceDatas").hide();
                $("#DevicePartDetail").hide();
                $("#DeviceMaintain").hide();
                $("#DeviceRepair").hide();
                $("#DevicePolling").hide();
                $("#OperateDetail").hide();
                $("#DevicePart").hide();
                SaveFlag = 1;
            } break;
            case 2: {
                $("#DeviceDatas").show();
                $("#BaseInfo").hide();
                $("#DevicePartDetail").hide();
                $("#DeviceMaintain").hide();
                $("#DeviceRepair").hide();
                $("#DevicePolling").hide();
                $("#OperateDetail").hide();
                $("#DevicePart").hide();
                SaveFlag = 1;
            } break;
            case 3: {
                if (!!!keyValue) {
                    dialogMsg('抱歉,请先保存基本信息！', 0);
                    return false;
                }
                $("#DevicePartDetail").show();
                $("#DeviceDatas").hide();
                $("#BaseInfo").hide();
                $("#DeviceMaintain").hide();
                $("#DeviceRepair").hide();
                $("#DevicePolling").hide();
                $("#OperateDetail").hide();
                $("#DevicePart").hide();
                SaveFlag = 2;
            } break;
            case 4: {
                $("#DeviceMaintain").show();
                $("#DeviceDatas").hide();
                $("#DevicePartDetail").hide();
                $("#BaseInfo").hide();
                $("#DeviceRepair").hide();
                $("#DevicePolling").hide();
                $("#OperateDetail").hide();
                $("#DevicePart").hide();
                SaveFlag = 1;
            } break;
            case 5: {
                $("#DeviceRepair").show();
                $("#DeviceDatas").hide();
                $("#DevicePartDetail").hide();
                $("#DeviceMaintain").hide();
                $("#BaseInfo").hide();
                $("#DevicePolling").hide();
                $("#OperateDetail").hide();
                $("#DevicePart").hide();
                SaveFlag = 1;
            } break;
            case 6: {
                $("#DevicePolling").show();
                $("#DeviceDatas").hide();
                $("#DevicePartDetail").hide();
                $("#DeviceMaintain").hide();
                $("#DeviceRepair").hide();
                $("#BaseInfo").hide();
                $("#OperateDetail").hide();
                $("#DevicePart").hide();
                SaveFlag = 1;
            } break;
            case 7: {
                $("#OperateDetail").show();
                $("#DeviceDatas").hide();
                $("#DevicePartDetail").hide();
                $("#DeviceMaintain").hide();
                $("#DeviceRepair").hide();
                $("#DevicePolling").hide();
                $("#BaseInfo").hide();
                $("#DevicePart").hide();
                SaveFlag = 1;
            } break;
            case 8: {
                $("#DevicePart").show();
                $("#OperateDetail").hide();
                $("#DeviceDatas").hide();
                $("#DevicePartDetail").hide();
                $("#DeviceMaintain").hide();
                $("#DeviceRepair").hide();
                $("#DevicePolling").hide();
                $("#BaseInfo").hide();
                SaveFlag = 1;
            } break;
        }
    }

    //初始化页面
    function InitialPage() {
        //layout布局
        $('#layout').layout({
            applyDemoStyles: true,
            onresize: function () {
                $(window).resize()
            }
        });
        $('.profile-nav').height($(window).height() - 20);
        $('.profile-content').height($(window).height() - 20);
        //resize重设(表格、树形)宽高
        $(window).resize(function (e) {
            window.setTimeout(function () {
                $('.profile-nav').height($(window).height() - 20);
                $('.profile-content').height($(window).height() - 20);
                $('#DevicePartTable').setGridWidth($('.profile-content').width());
                $("#DevicePartTable").setGridHeight($(window).height() - 181.5);
                $("#DeviceRepairTable").setGridHeight($(window).height() - 181.5);
            }, 200);
            e.stopPropagation();
        });

        //所属机构
        $("#OrganizeId").ComboBoxTree({
            url: "../../BaseManage/Organize/GetTreeJson",
            description: "==请选择所属机构==",
            height: "250px",
            click: function (data) {
                organizeid = data.id;
                //位置
                $("#PStructId").ComboBoxTree({
                    url: "../../ResourceManage/RS_PStructs/GetTreeJson?type=5&OrganizeId=" + organizeid,
                    height: "250px",
                    description: "==请选择=="
                });
            }
        });
        //所属类别
        $("#Type").ComboBoxTree({
            url: "../../ResourceManage/RS_DeviceType/GetTreeJson",
            description: "==请选择==",
            height: "230px",
            click: function (item) {
                DeviceId = item.id;
                Title = item.title;
                if (item.title == "1") {
                    dialogMsg('设备只能挂在类别最下级', 0);
                }
                else {
                    deviceTypeId = item.id;
                }
            }
        });
        //设备等级
        $("#Level").ComboBoxTree({
            url: "../../SystemManage/DataItemDetail/GetDataItemTreeJson",
            param: { EnCode: "DeviceLevel" },
            description: "==请选择==",
            height: "230px"
        });
        //使用状态
        $("#State").ComboBox({
            data: [{ "key": "1", "value": "在用" }, { "key": "2", "value": "停用" }, { "key": "3", "value": "报废" }, { "key": "4", "value": "闲置" }],
            id: "key",
            text: "value",
            description: "==请选择==",
            height: "150px"
        });
        //位置
        $("#PStructId").ComboBoxTree({
            height: "250px",
            description: "==请选择=="
        });
        //安装类型
        $("#InstallType").ComboBox({

            data: [{ "key": "1", "value": "单台运行" }, { "key": "2", "value": "一用一备" }, { "key": "3", "value": "二用一备" }, { "key": "4", "value": "多用一备" }, { "key": "5", "value": "一用多备" }],
            id: "key",
            text: "value",
            description: "==请选择==",
            height: "150px"
        });
        //关联设备
        $("#GLSB1").ComboBoxTree({
            description: "==请选择==",
            height: "220px",
        });
        //初始化时间
        $("#StartTime").val("@DateTime.Now.AddDays(-DateTime.Now.Day+1).ToString("yyyy-MM-dd")");
        $("#EndTime").val("@DateTime.Now.AddMonths(1).AddDays(- DateTime.Now.Day).ToString("yyyy-MM-dd")");
        $("#time_horizon").ComboBox({
            data: [{ "key": 2, "value": "上周" }, { "key": 1, "value": "本周" }, { "key": 4, "value": "上月" }, { "key": 3, "value": "本月" }, { "key": 5, "value": "本年" }],
            id: "key",
            text: "value",
            click: function (item) {

                var value = item.attr('data-value');
                switch (value) {
                    case "1"://本周
                        $("#StartTime").val("@DateTime.Now.AddDays(1 - DateTime.Now.DayOfWeek.GetHashCode()).ToString("yyyy-MM-dd")");
                        $("#EndTime").val("@DateTime.Now.AddDays(7 - DateTime.Now.DayOfWeek.GetHashCode()).ToString("yyyy-MM-dd")");
                        break;
                    case "2"://上周
                        $("#StartTime").val("@DateTime.Now.AddDays(1 - DateTime.Now.DayOfWeek.GetHashCode()-7).ToString("yyyy-MM-dd")");
                        $("#EndTime").val("@DateTime.Now.AddDays(7 - DateTime.Now.DayOfWeek.GetHashCode()-7).ToString("yyyy-MM-dd")");
                        break;
                    case "3"://本月
                        $("#StartTime").val("@DateTime.Now.AddDays(-DateTime.Now.Day+1).ToString("yyyy-MM-dd")");
                        $("#EndTime").val("@DateTime.Now.AddMonths(1).AddDays(- DateTime.Now.Day).ToString("yyyy-MM-dd")");
                        break;
                    case "4"://上月
                        $("#StartTime").val("@DateTime.Now.AddDays(-DateTime.Now.Day + 1).AddMonths(-1).ToString("yyyy-MM-dd")");
                        $("#EndTime").val("@DateTime.Now.AddDays(-DateTime.Now.Day).ToString("yyyy-MM-dd")");
                        break;
                    case "5"://本年
                        $("#StartTime").val("@DateTime.Now.AddDays(-DateTime.Now.DayOfYear + 1).ToString("yyyy-MM-dd")");
                        $("#EndTime").val("@DateTime.Now.AddMonths(12 - DateTime.Now.Month + 1).AddDays(-DateTime.Now.Day).ToString("yyyy-MM-dd")");
                        break;
                    default:
                        break;
                }
                $("#SelectedStartTime").html($("#StartTime").val());
                $("#SelectedEndTime").html($("#EndTime").val());
                SearchEventOne();
            }
        });
        $("#time_horizon").ComboBoxSetValue(3);

        //2
        $("#StartTimeTwo").val("@DateTime.Now.AddDays(-DateTime.Now.Day+1).ToString("yyyy-MM-dd")");
        $("#EndTimeTwo").val("@DateTime.Now.AddMonths(1).AddDays(- DateTime.Now.Day).ToString("yyyy-MM-dd")");
        $("#time_horizonTwo").ComboBox({
            data: [{ "key": 2, "value": "上周" }, { "key": 1, "value": "本周" }, { "key": 4, "value": "上月" }, { "key": 3, "value": "本月" }, { "key": 5, "value": "本年" }],
            id: "key",
            text: "value",
            click: function (item) {

                var value = item.attr('data-value');
                switch (value) {
                    case "1"://本周
                        $("#StartTimeTwo").val("@DateTime.Now.AddDays(1 - DateTime.Now.DayOfWeek.GetHashCode()).ToString("yyyy-MM-dd")");
                        $("#EndTimeTwo").val("@DateTime.Now.AddDays(7 - DateTime.Now.DayOfWeek.GetHashCode()).ToString("yyyy-MM-dd")");
                        break;
                    case "2"://上周
                        $("#StartTimeTwo").val("@DateTime.Now.AddDays(1 - DateTime.Now.DayOfWeek.GetHashCode()-7).ToString("yyyy-MM-dd")");
                        $("#EndTimeTwo").val("@DateTime.Now.AddDays(7 - DateTime.Now.DayOfWeek.GetHashCode()-7).ToString("yyyy-MM-dd")");
                        break;
                    case "3"://本月
                        $("#StartTimeTwo").val("@DateTime.Now.AddDays(-DateTime.Now.Day+1).ToString("yyyy-MM-dd")");
                        $("#EndTimeTwo").val("@DateTime.Now.AddMonths(1).AddDays(- DateTime.Now.Day).ToString("yyyy-MM-dd")");
                        break;
                    case "4"://上月
                        $("#StartTimeTwo").val("@DateTime.Now.AddDays(-DateTime.Now.Day + 1).AddMonths(-1).ToString("yyyy-MM-dd")");
                        $("#EndTimeTwo").val("@DateTime.Now.AddDays(-DateTime.Now.Day).ToString("yyyy-MM-dd")");
                        break;
                    case "5"://本年
                        $("#StartTimeTwo").val("@DateTime.Now.AddDays(-DateTime.Now.DayOfYear + 1).ToString("yyyy-MM-dd")");
                        $("#EndTimeTwo").val("@DateTime.Now.AddMonths(12 - DateTime.Now.Month + 1).AddDays(-DateTime.Now.Day).ToString("yyyy-MM-dd")");
                        break;
                    default:
                        break;
                }
                $("#SelectedStartTimeTwo").html($("#StartTimeTwo").val());
                $("#SelectedEndTimeTwo").html($("#EndTimeTwo").val());
                SearchEventTwo();
            }
        });
        $("#time_horizonTwo").ComboBoxSetValue(3);

        //3
        $("#StartTimeThree").val("@DateTime.Now.AddDays(-DateTime.Now.Day+1).ToString("yyyy-MM-dd")");
        $("#EndTimeThree").val("@DateTime.Now.AddMonths(1).AddDays(- DateTime.Now.Day).ToString("yyyy-MM-dd")");
        $("#time_horizonThree").ComboBox({
            data: [{ "key": 2, "value": "上周" }, { "key": 1, "value": "本周" }, { "key": 4, "value": "上月" }, { "key": 3, "value": "本月" }, { "key": 5, "value": "本年" }],
            id: "key",
            text: "value",
            click: function (item) {

                var value = item.attr('data-value');
                switch (value) {
                    case "1"://本周
                        $("#StartTimeThree").val("@DateTime.Now.AddDays(1 - DateTime.Now.DayOfWeek.GetHashCode()).ToString("yyyy-MM-dd")");
                        $("#EndTimeThree").val("@DateTime.Now.AddDays(7 - DateTime.Now.DayOfWeek.GetHashCode()).ToString("yyyy-MM-dd")");
                        break;
                    case "2"://上周
                        $("#StartTimeThree").val("@DateTime.Now.AddDays(1 - DateTime.Now.DayOfWeek.GetHashCode()-7).ToString("yyyy-MM-dd")");
                        $("#EndTimeThree").val("@DateTime.Now.AddDays(7 - DateTime.Now.DayOfWeek.GetHashCode()-7).ToString("yyyy-MM-dd")");
                        break;
                    case "3"://本月
                        $("#StartTimeThree").val("@DateTime.Now.AddDays(-DateTime.Now.Day+1).ToString("yyyy-MM-dd")");
                        $("#EndTimeThree").val("@DateTime.Now.AddMonths(1).AddDays(- DateTime.Now.Day).ToString("yyyy-MM-dd")");
                        break;
                    case "4"://上月
                        $("#StartTimeThree").val("@DateTime.Now.AddDays(-DateTime.Now.Day + 1).AddMonths(-1).ToString("yyyy-MM-dd")");
                        $("#EndTimeThree").val("@DateTime.Now.AddDays(-DateTime.Now.Day).ToString("yyyy-MM-dd")");
                        break;
                    case "5"://本年
                        $("#StartTimeThree").val("@DateTime.Now.AddDays(-DateTime.Now.DayOfYear + 1).ToString("yyyy-MM-dd")");
                        $("#EndTimeThree").val("@DateTime.Now.AddMonths(12 - DateTime.Now.Month + 1).AddDays(-DateTime.Now.Day).ToString("yyyy-MM-dd")");
                        break;
                    default:
                        break;
                }
                $("#SelectedStartTimeThree").html($("#StartTimeThree").val());
                $("#SelectedEndTimeThree").html($("#EndTimeThree").val());
                SearchEventThree();
            }
        });
        $("#time_horizonThree").ComboBoxSetValue(3);

        //完成状态
        $("#IsState").ComboBox({
            //  url: " ",
            data: [{ "key": "1", "value": "待完成" }, { "key": "2", "value": "已完成" }, { "key": "3", "value": "已取消" }],
            id: "key",
            text: "value",
            description: "所有",
            height: "150px",
            click: function (item) {
                SearchEventOne();
            }
        });
        //完成状态
        $("#IsStateTwo").ComboBox({
            //  url: " ",
            data: [{ "key": "1", "value": "待完成" }, { "key": "2", "value": "已完成" }, { "key": "3", "value": "已取消" }],
            id: "key",
            text: "value",
            description: "所有",
            height: "150px",
            click: function (item) {
                SearchEventTwo();
            }
        });
    }


    function initControl() {
        //获取表单
        if (!!keyValue) {
            $.SetForm({
                url: "../../ResourceManage/RS_Device/GetFormJson",
                param: { keyValue: keyValue },
                success: function (data) {
                    organizeid = data.OrganizeId;
                    //位置
                    $("#PStructId").ComboBoxTree({
                        url: "../../ResourceManage/RS_PStructs/GetTreeJson?OrganizeId=" + organizeid,
                        height: "250px",
                        description: "==请选择=="
                    });
                    //list = data.list;
                    $("#DeviceInfo").SetWebControls(data);
                    $("#OrganizeId").ComboBoxTreeSetValue(data.OrganizeId);
                    $("#Type").ComboBoxTreeSetValue(data.Type);
                    $("#ParentId").ComboBoxTreeSetValue(data.ParentId);
                    $("#PStructId").ComboBoxTreeSetValue(data.PStructId);
                    $("#VendorId").ComboBoxTreeSetValue(data.VendorId);
                    deviceTypeId = data.Type; Title = "0";
                    $(".profile-nav ul li").show();
                }
            });
        }
    }
    //侧面切换显示/隐藏
    //function profileSwitch(id) {
    //    if (id == "DeviceDatas") {
    //        if (logo == "1") {
    //            dialogMsg('抱歉,请先保存基本信息！', 0);
    //            return false;
    //        }
    //        else {
    //            $(".profile-content").find('.flag').hide()
    //            $(".profile-content").find("#" + id).show();
    //        }
    //    }
    //    else {
    //        $(".profile-content").find('.flag').hide()
    //        $(".profile-content").find("#" + id).show();
    //    }
    //};

    //设备参数
    function GetDatasGrid() {
        if (deviceTypeId == "") {
            dialogMsg('请选择设备类别', 0);
        }
        else {
            var otable = $("#DeviceDatasTable");
            if (!otable.html()) {
                $.ajax({
                    url: "/ResourceManage/RS_DeviceType/GetDatasList?keyValue=" + keyValue + "&DeviceTypeId=" + deviceTypeId,
                    type: "get",
                    dataType: "json",
                    success: function (data) {
                        otable.html("");
                        if (data.count > 0) {
                            otable.html(data.html);
                        }
                        else {
                            otable.html("<tr><td><a></a><span style='color:red;'>目前暂无设备参数</span></td></tr>");
                        }
                    },
                    error: function (e) {
                        alert(Error);
                    }
                });
            }
        }
    }

    //设备零配件
    function GetPartGrid() {
        if (deviceTypeId == "") {
            dialogMsg('请选择设备类别', 0);
        }
        else {
            var $gridTable = $("#DevicePartTable");
            $gridTable.jqGrid({
                datatype: "json",
                url: "/ResourceManage/RS_Device/GetPartssInstanceList?DeviceId=" + keyValue,
                height: $(window).height() - 181.5,
                autowidth: true,
                unwritten: false,
                colModel: [
                     { label: '主键', name: 'Id', hidden: true },
                     { label: '主键', name: 'DevicePartsId', hidden: true },
                     { label: '零配件名称', name: 'Name', width: 89, align: "left", sortable: false },
                     { label: '规格型号', name: 'ModelNo', width: 90, align: "left", sortable: false },
                     {
                         label: "单价", name: "UnitPrice", width: 90, align: "left", sortable: false,
                         formatter: function (cellvalue, options, rowObject) {
                             return !!cellvalue ? cellvalue : rowObject.Price;
                         }
                     },
                     { label: "数量", name: "Num", width: 90, align: "left", sortable: false },
                     { label: "金额", name: "Total", width: 90, align: "left", sortable: false },
                     { label: "生产厂商", name: "Factory", width: 90, align: "left", sortable: false },
                     { label: "创建时间", name: "CreateDate", width: 90, align: "left", sortable: false },
                     { label: "保修开始时间", name: "BeginDate", width: 90, align: "left", sortable: false },
                     { label: "保修停止时间", name: "EndDate", width: 90, align: "left", sortable: false },
                     { label: "保修厂商", name: "Verdors", width: 90, align: "left", sortable: false },
                     { label: "附加说明", name: "DeviceDescription", width: 200, align: "left", sortable: false }
                ],
                caption: "设备零配件",
                rowNum: "1000",
                rownumbers: true,
                viewrecords: true,
                shrinkToFit: false,
                gridview: true,
                hidegrid: false
            });
        }

    }

    //加载变更记录表格
    //function GetDevicePartDetailGrid() {
    //    var $gridTable = $("#DevicePartDetailTable");
    //    $gridTable.jqGrid({
    //        datatype: "json",
    //        url: "../../ResourceManage/RS_Device/GetDList?DeviceId=" + keyValue,
    //        height: $(window).height() - 141.5,
    //        autowidth: true,
    //        unwritten: false,
    //        colModel: [
    //             { label: '主键', name: 'Id', hidden: true },
    //              { label: '设备主键', name: 'DeviceId', hidden: true },
    //              { label: '设备名称', name: 'DeviceName', hidden: true },
    //              { label: '设备编号', name: 'DeviceCode', hidden: true },
    //              { label: '设备规格型号', name: 'DeviceModelNo', hidden: true },
    //            { label: '变更时间', name: 'ModifyDate', width: 89, align: "left", sortable: false },
    //                { label: '零配件名称', name: 'Name', width: 89, align: "left", sortable: false },
    //                 { label: '规格型号', name: 'ModelNo', width: 90, align: "left", sortable: false },
    //                { label: "单价", name: "Price", width: 90, align: "left", sortable: false },
    //                { label: "数量", name: "Num", width: 90, align: "left", sortable: false },
    //                { label: "金额", name: "Total", width: 90, align: "left", sortable: false },
    //                { label: "保修期限", name: "WarrantyPeriod", width: 90, align: "left", sortable: false },
    //                { label: "工单类型", name: "SourceType", width: 90, align: "left", sortable: false },
    //                { label: "工单编号", name: "SourceId", width: 90, align: "left", sortable: false },
    //                { label: "附加说明", name: "Description", width: 90, align: "left", sortable: false }
    //        ],
    //        caption: "部件变更记录",
    //        rowNum: "1000",
    //        rownumbers: true,
    //        shrinkToFit: false,
    //        gridview: true,
    //        hidegrid: false
    //    });
    //}
    //维修记录表格
    function GetDeviceRepairGrid() {
        var selectedRowIndex = 0;
        var $gridTable = $("#DeviceRepairTable");
        var queryJson = {
            OrganizeId: $("#OrganizeId").attr('data-value'),
            DeviceId: keyValue,
            StartTime: $("#StartTimeTwo").val(),
            EndTime: $("#EndTimeTwo").val(),
            State: $("#IsStateTwo").attr('data-value')
        };
        $gridTable.jqGrid({
            url: "../../ResourceManage/RS_Device/GetRepairList",
            postData: { queryJson: JSON.stringify(queryJson) },
            datatype: "json",
            height: $(window).height() - 181.5,
            autowidth: true,
            colModel: [
                  { label: "主键", name: "Id", hidden: true },
                { label: "工单编号", name: "Code", index: "Code", width: 150, align: "center", sortable: false },
                { label: "制单日期", name: "Date", index: "Date", width: 150, align: "center", sortable: false },
                { label: "报修内容", name: "RepairContent", index: "RepairContent", width: 100, align: "center", sortable: false },
                { label: "报修人", name: "RepairMan", index: "RepairMan", width: 120, align: "center", sortable: false },
                {
                    label: "完成状态", name: "State", index: "State", width: 100, align: "center", sortable: false,
                    formatter: function (cellvalue, options, rowObject) {
                        var Msg = "";
                        switch (cellvalue) {
                            case 1: Msg = "<span  class='label label-danger'>待处理</span>";
                                break;
                            case 2: Msg = "<span  class='label label-info'>派单中</span>";
                                break;
                            case 3: Msg = "<span  class='label label-info'>进行中</span>";
                                break;
                            case 4: Msg = "<span  class='label label-success'>已完成</span>";
                                break;
                            case 6: Msg = "<span  class='label label-warning'>未验收</span>";
                                break;
                            case 7: Msg = "<span  class='label label-success>已验收</span>";
                                break;
                            case 5: Msg = "<span  class='label label-inverse-learun'>不处理</span>";
                                break;
                            default: Msg = "---";
                                break;
                        }
                        return Msg;
                    }
                },
                { label: "维修人", name: "RepairedMan", index: "RepairedMan", width: 120, align: "center", sortable: false },
                { label: "维修开始日期", name: "BeginDate", index: "BeginDate", width: 150, align: "center", sortable: false },
                { label: "维修终止日期", name: "EndDate", index: "EndDate", width: 150, align: "center", sortable: false },
                { label: "验收人", name: "CheckMan", index: "CheckMan", width: 120, align: "center", sortable: false },
                { label: "附加说明", name: "Description", index: "Description", width: 90, align: "center", sortable: false },
            ],
            caption: "部件维修记录",
            rowNum: 30,
            rowList: [30, 50, 100],
            pager: "#gridPagerTwo",
            sortname: 'Date',
            sortorder: 'desc',
            rownumbers: true,
            shrinkToFit: false,
            gridview: true,
            hidegrid: false
        });
        //查询事件
        $("#btn_SearchTwo").click(function () {
            $(this).parent().parent().prev().trigger("click");
            $("#SelectedStartTimeTwo").html($("#StartTimeTwo").val());
            $("#SelectedEndTimeTwo").html($("#EndTimeTwo").val());
        });
    }

    //查询表格函数
    function SearchEventTwo() {
        var queryJson = {
            OrganizeId: $("#OrganizeId").attr('data-value'),
            DeviceId: keyValue,
            StartTime: $("#StartTimeTwo").val(),
            EndTime: $("#EndTimeTwo").val(),
            State: $("#IsStateTwo").attr('data-value')
        };
        $("#DeviceRepairTable").jqGrid('setGridParam', {
            postData: { queryJson: JSON.stringify(queryJson) }, page: 1
        }).trigger('reloadGrid');
    }

    //保养记录表格
    function GetDeviceMaintainGrid() {
        var selectedRowIndex = 0;
        var $gridTable = $("#DeviceMaintainTable");
        var queryJson = {
            OrganizeId: $("#OrganizeId").attr('data-value'),
            State: $("#State").attr('data-value'),
            BeginTime: $("#StartTime").val(),
            EndTime: $("#EndTime").val()
        };
        $gridTable.jqGrid({
            url: "../../ResourceManage/RS_Device/GetWeekList",
            postData: { queryJson: JSON.stringify(queryJson) },
            datatype: "json",
            height: $(window).height() - 181.5,
            autowidth: true,
            colModel: [
                 { label: 'ID', name: 'Id', hidden: true },
                { label: '工单编号', name: 'Code', width: 89, align: "left", sortable: false },
                    { label: '制单日期', name: 'Date', width: 150, align: "left", sortable: false },
                     { label: '工作项目', name: 'ItemName', width: 90, align: "left", sortable: false },
                    { label: "项目编号", name: "WeekPlanCode", width: 90, align: "left", sortable: false },
                    { label: "计划起始日期", name: "BeginDate", width: 200, align: "left", sortable: false },
                    { label: "计划终止日期", name: "EndDate", width: 200, align: "left", sortable: false },
                    {
                        label: "完成状态", name: "State", index: "State", width: 100, align: "center", sortable: false,
                        formatter: function (cellvalue, options, rowObject) {
                            var Msg = "";
                            switch (cellvalue) {
                                case 1: Msg = "<span  class='label label-danger'>待完成</span>";
                                    break;
                                case 2: Msg = "<span  class='label label-info'>已完成</span>";
                                    break;
                                case 3: Msg = "<span  class='label label-info'>已取消</span>";
                                    break;
                                case 4: Msg = "<span  class='label label-success'>已退</span>";
                                    break;
                                default: Msg = "---";
                                    break;
                            }
                            return Msg;
                        }
                    },
                    { label: "执行起始日期", name: "ExcuBeginTime", width: 200, align: "left", sortable: false },
                    { label: "执行终止日期", name: "ExecEndTime", width: 200, align: "left", sortable: false },
                    { label: "附加说明", name: "Description", width: 90, align: "left", sortable: false },
            ],
            caption: "部件保养记录",
            rowNum: 10000,
            rownumbers: true,
            shrinkToFit: false,
            gridview: true,
            hidegrid: false
        });
        //查询事件
        $("#btn_Search").click(function () {
            $(this).parent().parent().prev().trigger("click");
            $("#SelectedStartTime").html($("#StartTime").val());
            $("#SelectedEndTime").html($("#EndTime").val());
            SearchEventOne();
        });
    }

    //查询表格函数
    function SearchEventOne() {
        var queryJson = {
            OrganizeId: $("#OrganizeId").attr('data-value'),
            State: $("#State").attr('data-value'),
            BeginTime: $("#StartTime").val(),
            EndTime: $("#EndTime").val()
        };
        $("#DeviceMaintainTable").jqGrid('setGridParam', {
            postData: { queryJson: JSON.stringify(queryJson) }, page: 1
        }).trigger('reloadGrid');
    }


    //巡检记录表格
    function GetPollingGrid() {
        var selectedRowIndex = 0;
        var $gridTable = $("#DevicePollingTable");
        var queryJson = {
            Type: _TypeId,// "78351763-3ccf-4a1a-8e53-869cf7adfdfe",//8F09CCF7-5CD6-44C7-8C61-0BF24757FCC2
            BeginTime: $("#StartTime").val(),
            EndTime: $("#EndTime").val(),
            ObjectId: keyValue
        };
        $gridTable.jqGrid({
            url: "../../PropertyManage/CS_PollingResult/GetPollingDeviceItemInfo",
            postData: { "queryJson": JSON.stringify(queryJson) },
            datatype: "json",
            height: $(window).height() - 181.5,
            autowidth: true,
            colModel: [
                 { label: 'ID', name: 'Id', hidden: true },
                 { label: '巡检日期', name: 'Date', width: 89, align: "left", sortable: false },
                 { label: '巡检项目', name: 'Name', width: 89, align: "left", sortable: false },
                 { label: '巡检次数', name: 'Count', width: 150, align: "left", sortable: false },
                 {
                     label: "是否异常", name: "IsException", width: 80, align: "left", sortable: false, hidden: true,
                     formatter: function (cellvalue, options, rowObject) {
                         return cellvalue == 0 ? "0/" + rowObject.Count : "<span style='color:red'>" + cellvalue + "</span>/" + rowObject.Count;
                     }
                 }
            ],
            caption: "设备巡检记录",
            rowNum: 30,
            rowList: [30, 50, 100],
            pager: "#gridPagerThree",
            sortname: 'Date',
            sortorder: 'desc',
            rownumbers: true,
            shrinkToFit: false,
            gridview: true,
            hidegrid: false
        });
        //查询事件
        $("#btn_SearchThree").click(function () {
            $(this).parent().parent().prev().trigger("click");
            $("#SelectedStartTimeThree").html($("#StartTimeThree").val());
            $("#SelectedEndTimeThree").html($("#EndTimeThree").val());
        });
    }

    //查询表格函数
    function SearchEventThree() {
        var queryJson = {
            Type: _TypeId,// "78351763-3ccf-4a1a-8e53-869cf7adfdfe",//8F09CCF7-5CD6-44C7-8C61-0BF24757FCC2
            BeginTime: $("#StartTime").val(),
            EndTime: $("#EndTime").val(),
            ObjectId: keyValue
        };
        $("#DevicePollingTable").jqGrid('setGridParam', {
            postData: { "queryJson": JSON.stringify(queryJson) },
        }).trigger('reloadGrid');
    }

    ////新增零配件
    function btn_addPartInstance() {
        var gridData = $("#DevicePartTable").jqGrid("getRowData");
        var DevicePartsIds = "";
        if (gridData.length > 0) {
            for (var i = 0; i < gridData.length; i++) {
                DevicePartsIds += gridData[i].DevicePartsId + ",";
            }
        }
        dialogOpen({
            id: "DevicePartDetail",
            title: '新增零配件',
            url: '../../ResourceManage/RS_Device/DevicePartDetail?DevicePartsIds=' + DevicePartsIds + '&Type=' + deviceTypeId,
            width: "1100px",
            height: "700px",
            callBack: function (iframeId) {
                top.frames[iframeId].AcceptClick(function (data) {
                    //在这里处理提交过来的数据
                    console.log(data);
                    var $gridTable = $("#DevicePartTable");
                    $gridTable.addRowData(($gridTable.jqGrid("getRowData").length + 1), data);
                });
            }
        });
    }
    //删除零配件
    function btn_deletePartInstance() {
        var keyValue = $("#DevicePartTable").getGridParam('selrow');
        if (keyValue) {
            dialogConfirm('注：您确定要移除吗？该操作将无法恢复？', function (r) {
                if (r) {
                    $("#DevicePartTable").delRowData(keyValue);
                    dialogMsg("移除成功。", 1);
                }
            });

        } else {
            dialogMsg('请选择需要移除的数据！', 0);
        }
    }
    //修改零配件
    function btn_editPartInstance() {
        var RowId = $("#DevicePartTable").getGridParam('selrow');
        var PartId = $("#DevicePartTable").jqGridRowValue("Id");
        if (checkedRow(RowId)) {
            dialogOpen({
                id: "DevicePartDetail",
                title: '修改零配件',
                url: '../../ResourceManage/RS_Device/DevicePartDetail?keyValue=' + PartId + "&Rowid=" + RowId,
                width: "600px",
                height: "350px",
                callBack: function (iframeId) {
                    top.frames[iframeId].AcceptClick(function (data) {
                        //在这里处理提交过来的数据
                        console.log(data);
                        var $gridTable = $("#DevicePartTable");
                        $gridTable.setRowData(RowId, data);
                    });
                }
            });
        }
    }

    //保存表单
    function AcceptClick() {
        if (!$('#DeviceInfo').Validform()) {
            return false;
        }
        else if (Title == "1") {
            dialogMsg('设备只能挂在类别最下级', 0);
        }
        else {
            var postData = $("#DeviceInfo").GetWebControls(keyValue);
            if (postData["ParentId"] == "") postData["ParentId"] = "0";
            var PartsList = $("#DevicePartTable").jqGrid("getRowData");
            //自定义参数数据
            var DatasList = [];
            var Datas = $("#DeviceDatasTable").GetWebControls(keyValue);
            for (var propName in Datas) {
                var ObjectList = new Object();
                ObjectList.DeviceId = keyValue;
                ObjectList.DeviceDatasId = propName;
                ObjectList.Value = Datas[propName];
                DatasList.push(ObjectList);
            }
            //变更数据
            var PartListDatas = new Array;
            PartListDatas = $("#DevicePartDetailTable").jqGrid("getRowData");
            UploadFile();
            switch (SaveFlag) {
                case 1: {
                    $.SaveForm({
                        url: "../../ResourceManage/RS_Device/SaveForm?keyValue=" + keyValue,
                        param: { DeviceStr: JSON.stringify(postData), DatasStr: JSON.stringify(DatasList), PartsStr: JSON.stringify(PartsList) },
                        loading: "正在保存数据...",
                        success: function (data) {
                            $.currentIframe().$("#gridTable").trigger("reloadGrid");
                            keyValue = data.resultdata;
                            $(".profile-nav ul li").show();
                        }
                    });
                } break;
                case 2: {
                    $.SaveForm({
                        url: "../../ResourceManage/RS_Device/SaveDeviceParts",
                        param: { list: JSON.stringify(PartListDatas) },
                        loading: "正在保存数据",
                        success: function () {
                            $.currentIframe().$("#gridTable").trigger("reloadGrid");
                        }
                    });
                }
            }
        }

    }

</script>
<script>
    var list = [];
    var _length = 0;
    var fileFilter = [];
    var img_index = 0;
    var img_src = "";
    var arrFile = [];

    $(function () {
        //上传图片
        $('#fileImage').change(function () {
            var files = document.getElementById('fileImage').files;
            if (files.length > 0) {
                if (fileFilter.length > 0) {
                    for (var j = 0, fileb; fileb = fileFilter[j]; j++) {
                        arrFile.push(fileb);
                    }
                    for (var i = 0, filea; filea = files[i]; i++) {
                        var count = 0;
                        for (var j = 0, fileb; fileb = fileFilter[j]; j++) {

                            if (filea.name == fileb.name && filea.size == fileb.size) {
                                count++;
                            }
                        }
                        if (count == 0) {
                            arrFile.push(filea);
                        }
                    }
                    SetFile(arrFile);
                    arrFile = [];
                }
                else {
                    SetFile(files);
                    arrFile = [];
                }
            }
        });
        //计算居中位置
        var mg_top = ((parseInt($(window).height()) - parseInt($(".photo-div").height())) / 2);

        $(".photo-div").css({
            "margin-top": "" + mg_top + "px"
        });
        //关闭
        $(".photo-close").click(function () {
            $(".photo-mask").hide();
            $(".photo-panel").hide();
        });
        //下一张
        $(".photo-panel .photo-div .arrow-next").click(function () {
            img_index++;
            if (img_index >= $("#preview li img").length) {
                img_index = 0;
            }
            img_src = $("#preview li img").eq(img_index).attr("src");
            photoView($("#preview li img"));
        });
        //上一张
        $(".photo-panel .photo-div .arrow-prv").click(function () {
            img_index--;
            if (img_index < 0) {
                img_index = $("#preview li img").length - 1;
            }
            img_src = $("#preview li img").eq(img_index).attr("src");
            photoView($("#preview li img"));
        });
        //调用
        $(document).on("click", "#preview li img", function () {
            $(".photo-mask").show();
            $(".photo-panel").show();
            img_src = $(this).attr("src");
            img_index = $(this).parent().index();
            photoView($(this));
        });
    });
    //自适应预览
    function photoView(obj) {
        if ($(obj).width() >= $(obj).height()) {
            $(".photo-panel .photo-div .photo-img .photo-view-h").attr("class", "photo-view-w");
            $(".photo-panel .photo-div .photo-img .photo-view-w img").attr("src", img_src);
        } else {
            $(".photo-panel .photo-div .photo-img .photo-view-w").attr("class", "photo-view-h");
            $(".photo-panel .photo-div .photo-img .photo-view-h img").attr("src", img_src);
        }


    }
    //显示上传文件
    function SetFile(files) {
        fileFilter = files;
        var _html = "<ul>";
        for (var i = 0; i < files.length; i++) {
            if (files[i]) {
                if (files[i].constructor.name == "File") {
                    _html += "<li><a  title='删除'onclick='remove(this)'>x</a><img id='uploadImage_" + i + "'  filename='" + files[i].name + "' src='" + window.URL.createObjectURL(files[i]) + "'  /></li>";
                }
                else if (files[i].constructor.name == "Object") {
                    _html += "<li><a  title='删除' onclick='remove(this)'>x</a><img id='uploadImage_" + i + "'  filename='" + files[i].name + "' src='" + files[i].FileUrl + "'  /></li>";
                }
            }
        }
        _html += "</ul>"
        $("#preview").html(_html);
    }

    //删除上传图片
    function remove(obj) {

        var name = $(obj).next().attr("filename");
        for (var i = 0; i < fileFilter.length; i++) {
            if (fileFilter[i].name == name) {
                fileFilter = $.grep(fileFilter, function (value) {
                    return value != fileFilter[i];
                });
            }
        }
        $(obj).parent().remove();
    }
    //上传文件到后台
    function UploadFile() {
        $.ajaxFileUpload({
            url: "../../ResourceManage/RS_PStructs/UploadFile",
            secureuri: false,
            fileElementId: 'fileImage',
            dataType: 'json',
        });
    }
    function SetFileDisplay(dataArray) {
        var _html = "<ul>";

        if (dataArray.length > 0) {
            fileFilter = dataArray;
            for (var i = 0; i < dataArray.length; i++) {
                if (dataArray[i].Type == 21) {
                    _html += "<li style='float: left;'><img id='uploadImage_" + i + "' src='" + dataArray[i].FileUrl + "'  /></li>";
                }
            }
            _html += "</ul>";
            $("#preview").html(_html);
        }

    }
</script>
<div style="position:absolute;top:0; right:100px;z-index:1000;background:rgba(0, 0, 0, 0.1);padding:10px;border-radius:0px 0px 5px 5px;">
    <a class="btn btn-success" onclick="AcceptClick()">&nbsp;保存</a>
    @*<a class="btn btn-default">&nbsp;打印</a>*@
</div>
<div class="ui-layout" id="layout" style="height: 100%; width: 100%;">
    <div class="ui-layout-west" style="height: 100%; width: 100%;">
        <div class="west-Panel">
            <div class="profile-nav">
                <ul style="padding-top: 20px;">
                    <li class="active" id="li_BaseInfo" onclick="setDisplay(1)">基本信息</li>
                    <li id="li_DeviceDatas" onclick=" setDisplay(2), GetDatasGrid()">设备参数</li>
                    <li id="li_DevicePart" onclick=" setDisplay(8), GetPartGrid()">设备零配件</li>
                    @*<li id="li_DevicePartDetail" style="display:none;" onclick="setDisplay(3), GetDevicePartDetailGrid()">部件变更记录</li>*@
                    <li id="li_DeviceMaintain" style="display:none;" onclick="setDisplay(4), GetDeviceMaintainGrid()">保养记录</li>
                    <li id="li_DeviceRepair" style="display:none;" onclick="setDisplay(5), GetDeviceRepairGrid()">维修记录</li>
                    <li id="li_DevicePolling" style="display:none;" onclick="setDisplay(6), GetPollingGrid()">巡检记录</li>
                    <li id="li_OperateDetail" style="display:none;" onclick=" setDisplay(7)">业务日志</li>
                </ul>
            </div>
        </div>
    </div>
    <div class="ui-layout-center" style="height: 100%; width: 100%;">
        <div class="center-Panel">
            <div class="profile-content" style="background: #fff; ">
                <div id="BaseInfo" class="flag">
                    <div class="title">
                        基本信息
                    </div>
                    <table class="form" id="DeviceInfo">
                        <tr>
                            <th class="formTitle">所属机构<font face="宋体">*</font></th>
                            <td class="formValue">
                                <div id="OrganizeId" type="selectTree" class="ui-select" isvalid="yes" checkexpession="NotNull"></div>
                            </td>
                            <th class="formTitle">所属类别<font face="宋体">*</font></th>
                            <td class="formValue">
                                <div id="Type" type="selectTree" class="ui-select" isvalid="yes" checkexpession="NotNull"></div>
                            </td>
                            <th class="formTitle">设备等级</th>
                            <td class="formValue">
                                <div id="Level" type="selectTree" class="ui-select" isvalid="yes" checkexpession="NotNull"></div>

                            </td>
                        </tr>
                        <tr>
                            <td class="formTitle">设备名称<font face="宋体">*</font></td>
                            <td class="formValue">
                                <input id="Name" type="text"  class="form-control" placeholder="请输入设备名称" isvalid="yes" checkexpession="NotNull" />
                            </td>
                            <td class="formTitle">设备编号<font face="宋体">*</font></td>
                            <td class="formValue">
                                <input id="Code" type="text" onblur="$.ExistField(this.id, '../../ResourceManage/RS_Device/ExistCode')" class="form-control" placeholder="请输入设备编号" isvalid="yes" checkexpession="NotNull" />
                            </td>
                            <th class="formTitle">规格型号</th>
                            <td class="formValue">
                                <input id="ModelNo" type="text" class="form-control" />
                            </td>
                        </tr>
                        <tr>
                            <th class="formTitle">品牌</th>
                            <td class="formValue">
                                <input id="Brand" type="text" class="form-control" />
                            </td>
                            <th class="formTitle">数量<font face="宋体">*</font></th>
                            <td class="formValue">
                                <input id="Num" type="number" class="form-control" isvalid="yes" checkexpession="NotNull" />
                            </td>
                            <th class="formTitle">使用状态<font face="宋体">*</font></th>
                            <td class="formValue">
                                <div id="State" type="selectTree" class="ui-select" isvalid="yes" checkexpession="NotNull"></div>

                            </td>

                        </tr>
                        <tr>
                            <th class="formTitle">安装位置<font face="宋体">*</font></th>
                            <td colspan="2">
                                <div id="PStructId" type="selectTree" class="ui-select" isvalid="yes" checkexpession="NotNull"></div>
                            </td>
                            <td colspan="1">
                                <input id="PSMemo" type="text" class="form-control" />
                            </td>
                            <th class="formTitle">安装类型<font face="宋体">*</font></th>
                            <td class="formValue">
                                <div id="InstallType" type="selectTree" class="ui-select" isvalid="yes" checkexpession="NotNull"></div>
                            </td>
                        </tr>
                        <tr>
                            <th class="formTitle">投用日期</th>
                            <td class="formValue">
                                <input id="UseDate" type="text" class="form-control input-wdatepicker" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd ' })" />
                            </td>
                            <th class="formTitle">使用年限<font face="宋体">*</font></th>
                            <td class="formValue">
                                <input id="DateLimit" type="number" class="form-control" isvalid="yes" checkexpession="NotNull" />
                            </td>
                            <th class="formTitle">关联设备</th>
                            <td class="formValue">
                                <div id="GLSB1" type="selectTree" class="ui-select">

                                </div>
                            </td>
                        </tr>
                        <tr>
                            <th class="formTitle" valign="top" style="padding-top: 4px;">
                                附加说明
                            </th>
                            <td class="formValue" colspan="5">
                                <textarea id="Description" class="form-control" style="height: 70px;"></textarea>
                            </td>
                        </tr>

                        <tr style=" height: 20px; border-bottom: 1px dashed #cecece;"><td colspan="6"></td></tr>

                        <tr>
                            <td class="formTitle">出厂厂家</td>
                            <td class="formValue">
                                <input id="Factory" type="text" class="form-control" />
                            </td>
                            <td class="formTitle">出厂序号</td>
                            <td class="formValue">
                                <input id="FactoryNo" type="text" class="form-control" />
                            </td>
                            <th class="formTitle">出厂日期</th>
                            <td class="formValue">
                                <input id="FactoryDate" type="text" class="form-control input-wdatepicker" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd ' })" />
                            </td>
                        </tr>
                        <tr>
                            <td class="formTitle">交接日期</td>
                            <td class="formValue">
                                <input id="TransferDate" type="text" class="form-control input-wdatepicker" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd ' })" />
                            </td>
                            <td class="formTitle">维保商</td>
                            <td class="formValue">
                                <div id="VendorId" type="selectTree" class="ui-select"></div>
                            </td>
                            <th class="formTitle">维保期间</th>
                            <td class="formValue">
                                <div class="input-group">
                                    <input id="MaintenanceBeginDate" type="text" class="form-control input-wdatepicker" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd ' })" />
                                    <span class="input-group-addon"> - </span>
                                    <input id="MaintenanceEndDate" type="text" class="form-control input-wdatepicker" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd ' })" />
                                </div>
                            </td>
                        </tr>
                        <tr style=" height: 20px; border-bottom: 1px dashed #cecece;"><td colspan="6"></td></tr>
                        <tr>
                            <th class="formTitle">资产类别</th>
                            <td class="formValue">
                                <input id="AssetsClass" type="text" class="form-control" />
                            </td>
                            <th class="formTitle">资产编号</th>
                            <td class="formValue">
                                <input id="AssetsCode" type="text" class="form-control" />
                            </td>
                            <th class="formTitle">折旧率</th>
                            <td class="formValue">
                                <div class="input-group">
                                    <input id="DepreciationRate" type="number" class="form-control" />
                                    <span class="input-group-addon">折旧年限</span>
                                    <input id="DepreciatedYear" type="number" class="form-control" />
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <th class="formTitle">购买日期</th>
                            <td class="formValue">
                                <input id="PurchaseDate" type="text" class="form-control input-wdatepicker" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd ' })" />
                            </td>
                            <th class="formTitle">原值</th>
                            <td class="formValue">
                                <div class="input-group">
                                    <input id="DescriptionRate" type="number" class="form-control" />
                                    <span class="input-group-addon">折旧月数</span>
                                    <input id="DepreciatedMonth" type="number" class="form-control" />
                                </div>
                            </td>
                            <th class="formTitle">累计折旧</th>
                            <td class="formValue">
                                <div class="input-group">
                                    <input id="DTotalCount" type="number" class="form-control" />
                                    <span class="input-group-addon">残值</span>
                                    <input id="STotalCount" type="number" class="form-control" />
                                </div>
                            </td>
                        </tr>
                        <tr style=" height: 20px; border-bottom: 1px dashed #cecece;"><td colspan="6"></td></tr>
                        <tr>
                            <td colspan="6">
                                <div class="panel-Title" style="border:0px;">附件</div>
                                <div class="box" style="height: 100px;">
                                    <img style="position: relative; float: left; width: 60px; height: 60px;" src="~/Content/images/icon_app_add.png" />
                                    <input id="fileImage" type="file" size="30" class="BaseClass" name="fileselect[]" multiple="multiple" style="position: absolute; width: 60px; height: 60px; opacity: 0;" />
                                    <div id="preview" class="upload_preview"></div>
                                    <div class="photo-mask"></div>
                                    <div class="photo-panel">
                                        <div class="photo-div">
                                            <div class="photo-left">
                                                <div class="arrow-prv "></div>
                                            </div>
                                            <div class="photo-img">
                                                <div class="photo-bar">
                                                    <div class="photo-close"></div>
                                                </div>
                                                <div class="photo-view-h">
                                                    <img src="" />
                                                </div>
                                            </div>
                                            <div class="photo-right">
                                                <div class="arrow-next"></div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    </table>
                </div>
                <div id="DeviceDatas" class="flag" style="display:none">
                    <div class="title">
                        设备参数
                    </div>
                    <table class="form" id="DeviceDatasTable"></table>
                </div>
                <div id="DevicePart" class="flag" style="display:none">
                    <div class="title">
                        设备零配件
                    </div>
                    <div class="toolbar" style="height:41px;padding:5px;">
                        <div class="btn-group" style="float:right;">
                            <label id="lr-addPartInstance" class="btn btn-default" onclick="btn_addPartInstance()"><i class="fa fa-plus"></i>&nbsp;添加</label>
                            <label id="lr-editPartInstance" class="btn btn-default" onclick="btn_editPartInstance()"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</label>
                            <label id="lr-deletePartInstance" class="btn btn-default" onclick="btn_deletePartInstance()"><i class="fa fa-trash-o"></i>&nbsp;移除</label>
                        </div>
                        <script>$('.toolbar').authorizeButton()</script>
                    </div>
                    <table class="form" id="DevicePartTable"></table>
                </div>
                @*<div id="DevicePartDetail" style="display:none">
                        <div class="title">
                            部件变更记录
                        </div>
                        <div class="toolbar" style="margin-left:1300px">
                            <div class="btn-group">
                                <label id="lr-add" class="btn btn-default" onclick="btn_add()"><i class="fa fa-plus"></i>&nbsp;新增</label>
                                <label id="lr-edit" class="btn btn-default" onclick="btn_edit()"><i class="fa fa-pencil-square-o"></i>&nbsp;编辑</label>
                                <label id="lr-delete" class="btn btn-default" onclick="btn_delete()"><i class="fa fa-trash-o"></i>&nbsp;删除</label>
                            </div>
                        </div>
                        <table id="DevicePartDetailTable"></table>
                    </div>*@
                <div id="DeviceMaintain" style="display:none">
                    <div class="title">
                        保养记录
                    </div>
                    <div class="titlePanel">
                        <div class="title-search">
                            <table>
                                <tr>
                                    <td>查询条件</td>
                                    <td style="padding-left: 10px;">
                                        <div class="ui-filter" style="width: 200px;  ">
                                            <div class="ui-filter-text">
                                                <strong id="SelectedStartTime">@DateTime.Now.AddDays(-DateTime.Now.Day + 1).ToString("yyyy-MM-dd")</strong> 至 <strong id="SelectedEndTime">@DateTime.Now.AddMonths(1).AddDays(-DateTime.Now.Day).ToString("yyyy-MM-dd")</strong>
                                            </div>
                                            <div class="ui-filter-list" style="width: 350px;">
                                                <table class="form" id="filter-form">
                                                    <tr>
                                                        <th class="formTitle">发布时间：</th>
                                                        <td class="formValue">
                                                            <div style="float: left; width: 45%;">
                                                                <input id="StartTime" readonly type="text" value="@DateTime.Now.AddDays(-DateTime.Now.Day + 1).ToString("yyyy-MM-dd")" class="form-control input-wdatepicker" onfocus="WdatePicker()">
                                                            </div>
                                                            <div style="float: left; width: 10%; text-align: center;">至</div>
                                                            <div style="float: left; width: 45%;">
                                                                <input id="EndTime" readonly type="text" value="@DateTime.Now.AddMonths(1).AddDays(- DateTime.Now.Day).ToString("yyyy-MM-dd")" class="form-control input-wdatepicker" onfocus="WdatePicker()">
                                                            </div>
                                                        </td>
                                                    </tr>
                                                </table>
                                                <div class="ui-filter-list-bottom">
                                                    <a id="btn_Reset" class="btn btn-default">&nbsp;重&nbsp;&nbsp;置</a>
                                                    <a id="btn_Search" class="btn btn-primary">&nbsp;查&nbsp;&nbsp;询</a>
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                    <td style="padding-left: 10px;">
                                        <div id="time_horizon" type="selectTree" class="ui-select" style="width: 60px;"></div>
                                    </td>
                                    <td style="padding-left: 10px;">完成状态</td>
                                    <td style="padding-left: 10px;">
                                        <div id="IsState" type="select" class="ui-select" style="width: 80px;"></div>
                                    </td>
                                </tr>
                            </table>

                        </div>

                        <div class="toolbar">
                            <div class="btn-group">
                                <a id="lr-replace" class="btn btn-default" onclick="reload();"><i class="fa fa-refresh"></i>&nbsp;刷新</a>
                                @*<a id="lr-flowpreview" class="btn btn-default" onclick="btn_flowpreview()"><i class="fa fa-eye"></i>&nbsp;查看</a>*@
                            </div>
                        </div>
                    </div>
                    <table id="DeviceMaintainTable"></table>
                    @*<div id="gridPager"></div>*@
                </div>
                <div id="DeviceRepair" style="display:none">
                    <div class="title">
                        维修记录
                    </div>
                    <div class="titlePanel">
                        <div class="title-search">
                            <table>
                                <tr>
                                    <td>查询条件</td>
                                    <td style="padding-left: 10px;">
                                        <div class="ui-filter" style="width: 200px;  ">
                                            <div class="ui-filter-text">
                                                <strong id="SelectedStartTimeTwo">@DateTime.Now.AddDays(-DateTime.Now.Day + 1).ToString("yyyy-MM-dd")</strong> 至 <strong id="SelectedEndTimeTwo">@DateTime.Now.AddMonths(1).AddDays(-DateTime.Now.Day).ToString("yyyy-MM-dd")</strong>
                                            </div>
                                            <div class="ui-filter-list" style="width: 350px;">
                                                <table class="form" id="filter-form">
                                                    <tr>
                                                        <th class="formTitle">发布时间：</th>
                                                        <td class="formValue">
                                                            <div style="float: left; width: 45%;">
                                                                <input id="StartTimeTwo" readonly type="text" value="@DateTime.Now.AddDays(-DateTime.Now.Day + 1).ToString("yyyy-MM-dd")" class="form-control input-wdatepicker" onfocus="WdatePicker()">
                                                            </div>
                                                            <div style="float: left; width: 10%; text-align: center;">至</div>
                                                            <div style="float: left; width: 45%;">
                                                                <input id="EndTimeTwo" readonly type="text" value="@DateTime.Now.AddMonths(1).AddDays(- DateTime.Now.Day).ToString("yyyy-MM-dd")" class="form-control input-wdatepicker" onfocus="WdatePicker()">
                                                            </div>
                                                        </td>
                                                    </tr>
                                                </table>
                                                <div class="ui-filter-list-bottom">
                                                    <a id="btn_ResetTwo" class="btn btn-default">&nbsp;重&nbsp;&nbsp;置</a>
                                                    <a id="btn_SearchTwo" class="btn btn-primary">&nbsp;查&nbsp;&nbsp;询</a>
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                    <td style="padding-left: 10px;">
                                        <div id="time_horizonTwo" type="selectTree" class="ui-select" style="width: 60px;"></div>
                                    </td>
                                    <td style="padding-left: 10px;">完成状态</td>
                                    <td style="padding-left: 10px;">
                                        <div id="IsStateTwo" type="select" class="ui-select" style="width: 80px;"></div>
                                    </td>
                                </tr>

                            </table>

                        </div>

                        <div class="toolbar">
                            <div class="btn-group">
                                <a id="lr-replace" class="btn btn-default" onclick="reload();"><i class="fa fa-refresh"></i>&nbsp;刷新</a>
                                <a id="lr-flowpreview" class="btn btn-default" onclick="btn_flowpreview()"><i class="fa fa-eye"></i>&nbsp;查看</a>
                            </div>
                        </div>
                    </div>
                    <table id="DeviceRepairTable"></table>
                    <div id="gridPagerTwo"></div>
                </div>
                <div id="DevicePolling" style="display:none">
                    <div class="title">
                        巡检记录
                    </div>
                    <div class="titlePanel">
                        <div class="title-search">
                            <table>
                                <tr>
                                    <td>查询条件</td>
                                    <td style="padding-left: 10px;">
                                        <div class="ui-filter" style="width: 200px;  ">
                                            <div class="ui-filter-text">
                                                <strong id="SelectedStartTimeThree">@DateTime.Now.AddDays(-DateTime.Now.Day + 1).ToString("yyyy-MM-dd")</strong> 至 <strong id="SelectedEndTimeThree">@DateTime.Now.AddMonths(1).AddDays(-DateTime.Now.Day).ToString("yyyy-MM-dd")</strong>
                                            </div>
                                            <div class="ui-filter-list" style="width: 350px;">
                                                <table class="form" id="filter-form">
                                                    <tr>
                                                        <th class="formTitle">发布时间：</th>
                                                        <td class="formValue">
                                                            <div style="float: left; width: 45%;">
                                                                <input id="StartTimeThree" readonly type="text" value="@DateTime.Now.AddDays(-DateTime.Now.Day + 1).ToString("yyyy-MM-dd")" class="form-control input-wdatepicker" onfocus="WdatePicker()">
                                                            </div>
                                                            <div style="float: left; width: 10%; text-align: center;">至</div>
                                                            <div style="float: left; width: 45%;">
                                                                <input id="EndTimeThree" readonly type="text" value="@DateTime.Now.AddMonths(1).AddDays(- DateTime.Now.Day).ToString("yyyy-MM-dd")" class="form-control input-wdatepicker" onfocus="WdatePicker()">
                                                            </div>
                                                        </td>
                                                    </tr>
                                                </table>
                                                <div class="ui-filter-list-bottom">
                                                    <a id="btn_ResetThree" class="btn btn-default">&nbsp;重&nbsp;&nbsp;置</a>
                                                    <a id="btn_SearchThree" class="btn btn-primary">&nbsp;查&nbsp;&nbsp;询</a>
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                    <td style="padding-left: 10px;">
                                        <div id="time_horizonThree" type="selectTree" class="ui-select" style="width: 60px;"></div>
                                    </td>
                                </tr>

                            </table>

                        </div>

                        <div class="toolbar">
                            <div class="btn-group">
                                <a id="lr-replace" class="btn btn-default" onclick="reload();"><i class="fa fa-refresh"></i>&nbsp;刷新</a>
                                <a id="lr-flowpreview" class="btn btn-default" onclick="btn_flowpreview()"><i class="fa fa-eye"></i>&nbsp;查看</a>
                            </div>
                        </div>
                    </div>
                    <table id="DevicePollingTable"></table>
                    @*<div id="gridPagerThree"></div>*@
                </div>
                <div id="OperateDetail" style="display:none">
                    <div class="title">
                        业务日志
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
